<template>
    <ynet-content id="maxConn" :headerInformation="true" :headerMenu="true">
        <div>
            <div>
                <el-form class="formEmbedTable mt20" :model="toDetail">
                    <table> 
                        <tr>
                            <td>Transaction Sequence No.</td>
                            <td colspan='3'> {{toDetail.flowNo}} </td> 		
                        </tr>
                        <tr>
                            <td>Action</td>
                            <td> {{toDetail.actionType==0?"Add":toDetail.actionType==1?"Modify":toDetail.actionType==2?"Delete":""}} </td>
                            <td>Submit</td>
                            <td> {{toDetail.userAlias}} </td>	
                        </tr>
                    </table>
                </el-form>
                <el-form class="formEmbedTable mt20" :model="detailData">
                    <table> 
                        <tr>
                            <td>Parameter ID:</td>
                            <td colspan='3'> {{detailData.paramCode}} </td> 			
                        </tr>
                        <tr>
                            <td>Parameter</td>
                            <td> {{detailData.paramValue}} </td>
                            <td>Desciption</td>
                            <td> {{detailData.paramName}} </td>
                        </tr>
                    </table>
                </el-form>
            </div>
            <div class="btnArea mt20 tac">
                <el-button type="primary" @click="agree()">Approve</el-button>
                <el-button type="primary" @click="rules()">Reject</el-button>
                <el-button type="primary" icon="close" @click="back">Back</el-button>
            </div>
        </div>
         <!--拒绝页面弹窗-->
        <el-dialog :visible.sync="dialogTableVisible" :close-on-click-modal="false" :close-on-press-escape="false">
            <el-form ref="rejectForm" :model="rejectForm" class="formEmbedTable">
                <table>
                    <caption>Refusal reason</caption>
                    <tr>
                        <td>Refusal reason</td>
                        <td>
                            <el-form-item prop="rejReason">
                                <el-input placeholder="Refusal reason" v-model="rejectForm.rejReason"></el-input>
                            </el-form-item>
                        </td>
                    </tr>
                </table>
                <div class="btnArea mt20 tac">
                    <el-button type="primary" @click="dialogTableVisible = false,reject()">Confirm</el-button>
                </div>
            </el-form>
        </el-dialog>
        <!--拒绝页面弹窗end-->
    </ynet-content>
</template>

<script>
	export default {
		name:'maxConn',
		components:{
          
		},
        props:['detailData','toDetail',],
		data(){
            return { 
                rejectForm:{//审核拒绝列表
                    bsnAuthList:[],authFlag:'1',rejReason:'',
                },
                agreeForm:{
                    bsnAuthList:[],authFlag:'0',
                },
                dialogTableVisible:false,
            }   
        },
        mounted(){
            //let user =this.$tools.storage.get("user", "save") 
            //console.log("登录页浏览器缓存" + JSON.stringify(user))  
            //this.queryForm.userNo=user.userNo;
            //this.agreeForm.userNo=user.userNo;
            //this.rejectForm.userNo=user.userNo;
        },
		methods:{ 
            back(){
                this.$emit("back")
            },
            rules(){//判断是否选中数据
               this.dialogTableVisible=true;
            },
            agree(){
               //判断是否选中数据
                console.log("toDetail"+JSON.stringify(this.toDetail))
                this.agreeForm.bsnAuthList.push(this.toDetail);
                console.log("agreeForm"+JSON.stringify(this.agreeForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.agreeForm).then(data=>{
                    //console.log("data"+JSON.stringify(data))
                    if(data.body.errorCode==0){
                        this.$message({
                            type:'success',
                            message:'Success',
                            showClose:true,
                        })
                        this.$emit("back")
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },
            reject(){
                this.rejectForm.bsnAuthList.push(this.toDetail);
                console.log("rejectForm"+JSON.stringify(this.rejectForm))
                this.$tools.request(this,this.toDetail.bsnCode+"AuthAction.do",this.rejectForm).then(data=>{
                    if(data.body.errorCode==0){
                        this.$message({
                            type:'success',
                            message:'Success',
                            showClose:true,
                        })
                        this.$emit("back")
                    }else{
                        this.$alert("System Error Try again", "warning",{
                            confirmButtonText: 'Confirm',
                            callback: action => {
                            }
                        })
                    }
                })
            },

		}
	}
</script>